﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fis.Win.Utils
{
    public class AppConfig
    {
        static string service = "service.asmx";
        static string state = "state.htm";

        static Agile.Engine.Service.IClientServiceProxy ClientProxy = null;
        static object syncRoot = new object();

        public static Agile.Engine.Service.IClientServiceProxy CreateProxyInstance()
        {
            lock (syncRoot)
            {
                if (ClientProxy == null)
                {
                    lock (syncRoot)
                    {
                        var uri = System.Configuration.ConfigurationManager.AppSettings["Service"];
                        var timeout = System.Configuration.ConfigurationManager.AppSettings["Timeout"];

                        ClientProxy = new Agile.Engine.Service.ClientServiceProxy(uri + service, int.Parse(timeout));
                    }
                }
            }

            return ClientProxy;
        }

        public static string ServiceState
        {
            get
            {
                var uri = System.Configuration.ConfigurationManager.AppSettings["Service"];
                return uri + state;
            }
        }
    }
}
